#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
 
//#define KEY2_ENTER 25
#define KEY3_ENTER 28
//同时驱动两个键失败  key2被系统占用
 
struct key_event{
	int code;
	int value;
};
struct key_event event;
 
int main()
{
	int fd;
 
	fd = open("/dev/key",O_RDWR);
	if(fd < 0){
		perror("open");
		exit(-1);
	}
	
	while(1){
		read(fd,&event,sizeof(struct key_event));
	/*	if(event.code == KEY2_ENTER){
			if(event.value == 1){
				printf("user key2 up\n");
			}else{
				printf("user key2 down\n");
			}
		}else*/
		if(event.code == KEY3_ENTER){
			if(event.value == 1){
				printf("user key3 up\n");
			}else{
				printf("user key3 down\n");
			}
		}else{
 
		}
	}
	close(fd);
	
	return 0;
}
